# -*- coding: utf-8 -*-#
# ----------------------------------------*_*
# Author:       Chasetity
# Date:         2021/7/6
# ----------------------------------------*_*

import time

from appium import webdriver

#定义app相关参数字典
from selenium.webdriver.common.by import By

des_cap = {
    'platformName':'android',   #表示系统
    'platformVersion':'7.1.2',  #系统版本
    'deviceName':'127.0.0.1:62001',  #设备名称
    'appPackage':'com.android.settings',  #表示app包名
    'appActivity':'.Settings', #表示app界面名称
}

driver = webdriver.Remote('http://localhost:4723/wd/hub',des_cap)  # appium服务器地址，app相关参数字典
time.sleep(5)

ele = driver.find_element(By.XPATH,'//*[@text="更多"]')
ele.click()
time.sleep(2)

air_ele = driver.find_element(By.ID,'android:id/switch_widget')
air_ele.click()
time.sleep(2)

ret_ele = driver.find_element(By.CLASS_NAME,'android.widget.ImageButton')
ret_ele.click()
time.sleep(2)

driver.find_element(By.ID,'android:id/icon').click()
time.sleep(2)

driver.quit()